const userUtils = require("../../utils/user");
const validate = require('../../utils/validate')
const common = require('../../utils/common')
const { queryWaitReceived } = require('../../services/order')

Page({
  data: {
    orderList: [],
  },
  onLoad: function () {
    this.getOrderList()
  },
  getOrderList: function () {
    queryWaitReceived().then(res => {
      this.setData({
        orderList: res.data
      })
    }).catch(err => {
      common.log(err)
    })
  },
  goDetail: function (e) {
    const { index } = e.currentTarget.dataset;
    const currentData = this.data.orderList[index]
    wx.navigateTo({ url: `/pages/collection-products/index?data=${JSON.stringify(currentData)}` })
  },
  makePhoneCall: function (e) {
    const { phone } = e.currentTarget.dataset;
    wx.makePhoneCall({
      phoneNumber: phone
    })
  }
})
